/*
 * @Author: your name
 * @Date: 2021-10-17 22:08:53
 * @LastEditTime: 2021-10-17 22:18:56
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \luogu\动态规划\背包\多重背包\模板代码\main.cpp
 */
#include<iostream>
#include<algorithm>
using namespace std;

int f[100];

int vv[100],ww[100];

int main(){
    //物品数 背包容量
    int n,m;
    cin >> n >> m;
    int num=1;
    for(int i=1; i<=n; i++){
        int v,w,s;
        cin >> v >> w >> s;
        //二进制处理
        for(int j=1; j<=s; j<<=1){
            vv[num] = v*j;
            ww[num++] = w*j;
            s -= j;
        }
        //不足2的幂次,单独存储
        if(s){
            vv[num] = v*s;
            ww[num++] = w*s;
        }
    }
    //对vv[] 和 ww[]进行01背包处理
    for(int i=1; i<num; i++){
        for(int j=m; j>=vv[i]; j--){
            f[j] = max(f[j],f[j-vv[i]]+ww[i]);
        }
    }
    cout << f[m] << endl;
    return 0;
}
